App({
  onLaunch(options) {
    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)

    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
      }
    })

    let that = this;
    // 判断是否由分享进入小程序  从分享进入小程序时 返回上一级按钮不应该存在
    if (options.scene == 1007 || options.scene == 1008) {
      that.globalData.isShare = false;
    } else {
      that.globalData.isShare = false;
    };

    const {
      statusBarHeight,
      platform
    } = wx.getSystemInfoSync(); //获取系统信息

    const {
      top,
      height
    } = wx.getMenuButtonBoundingClientRect();

    that.globalData.platform = platform;
    //状态栏高度
    that.globalData.statusBarHeight = statusBarHeight;
    // 胶囊按钮高度 一般是32px 如果获取不到就使用32px
    that.globalData.menuButtonHeight = height ? height : 32;
    // 判断胶囊按钮信息是否成功获取
    if (top && top !== 0 && height && height !== 0) {
      // 导航栏高度
      that.globalData.navigationBarHeight = (top - statusBarHeight) * 2 + height
    } else {
      //个别手机获取不到 根据机型进行赋值
      that.globalData.navigationBarHeight = platform === 'android' ? 48 : 40
    }
    //用于绝对定位 占用空间
    that.globalData.navigationBarAndStatusBarHeight = that.globalData.navigationBarHeight + that.globalData.statusBarHeight;
  },
  globalData: {
    // userInfo: null,
    statusBarHeight: 0, //状态栏高度
    menuButtonHeight: 0, //胶囊按钮高度 
    navigationBarHeight: 0, //计算得出的导航栏高度
    navigationBarAndStatusBarHeight: 0, //导航栏和状态栏高度之和
    platform: "", //手机型号 android 或 IOS
    isShare: false, //是否由分享而来
    //用户信息
    userInfo:{
    },
    // 用户id
    userId:null
  }
})